/**
This file is part of dbdjasperreport.

Copyright (C) 2008 Kue Vang aka Kou
Licensed under the Eclipse Public License, Version 1.0; 
you may not use this file except in compliance with the License. 
You may obtain a copy of the License at http://www.eclipse.org/legal/epl-v10.html 
Unless required by applicable law or agreed to in writing, software 
distributed under the License is distributed on an "AS IS" BASIS, 
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language governing permissions and limitations 
under the License.
**/

import java.io.Serializable

class DataTypeService implements Serializable {
	List dataType = new ArrayList()
	
	static final String dateDataType = "1"
	static final String numDataType = "2"
	static final String strDataType = "3"
	static final String codeDataType = "4"
	static final String imageDataType = "5"
	static final String rtfDataType = "6"
	static final String entityDataType = "7"
	static final String booleanDataType = "8"
	static final String yesNoDataType = "9"
	
	def String getDataTypeDesc(String id){
		//String strId = id.toString()
		loadDataType()
		for(int i=0;i<dataType.size();i++){
			Code code = dataType[i]
			if(id==code.id)
				return code.codeDesc
		}
	}
	
	def String getDataTypeDesc(Integer id){
		String strId = id.toString()
		getDataTypeDesc(strId)
	}
	
	def List loadDataType(){
		if(!dataType){
			dataType.add(getDataType(dateDataType,"DATE"))
			dataType.add(getDataType(numDataType,"NUMBER"))
			dataType.add(getDataType(strDataType,"STRING"))
			dataType.add(getDataType(codeDataType,"CODE"))
			dataType.add(getDataType(imageDataType,"IMAGE"))
			dataType.add(getDataType(rtfDataType,"RTF"))
			dataType.add(getDataType(entityDataType,"ENTITY"))
			dataType.add(getDataType(booleanDataType,"BOOLEAN"))
			dataType.add(getDataType(yesNoDataType,"YES/NO"))
		}
		dataType
	}
	
	def Code getDataType(String id,String desc){
		Code type = new Code()
		type.setId(id)
		type.setCodeDesc(desc)
		type
	}	
}